<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // ES5 中的继承
        function Public(n1, n2) {
            this.num = n1;
            this.price = n2;
        }
        Public.prototype.total = function () {
            return this.num * this.price;
        }

        // 声明子类
        function Goods(name, n, p) {
            Public.call(this, n, p);
            this.goodsName = name;
        }
        Goods.prototype = Object.create(Public.prototype);
        Goods.prototype.constructor = Goods;

        var g1 = new Goods('导弹', 10, 35);
        console.log(g1);

    </script>
</body>

</html>